package ar.com.binarit

class PersonTagLib {

	def personService
	static namespace = "my"
	
	def infoHeadPerson = {attrs ->
		def logeado = session.user
		def legajo
		if(logeado){
			legajo = logeado.username
		}
		out << g.render(template:"/templates/mainPersonMenu", model:['person':logeado, 'personDetail':null])
	}
	
	def avatarPerson = {attrs ->
		def person = attrs.person
		def size = "tt_avatar-person tt"
		if(attrs.size.equals('mini')){
			size += " tt_avatar-person-min"
		}
		
		if(attrs.size.equals('large')){
			size += " tt_avatar-person-large"
		}
		
		if(attrs.size.equals('xlarge')){
			size += " tt_avatar-person-xlarge"
		}
		
		if(attrs.size.equals('xmini')){
			size += " tt_avatar-person-xmin"
		}
		
		def url
		def alt
		//		if(person){
//			url = person.URLFoto
//			alt = person.username
//		}else{
//			url = personService.urlFoto(attrs.usuario?.legajo)
//			alt = attrs.usuario.legajo
//		}
		url = "https://twimg0-a.akamaihd.net/profile_images/2865232017/895b7ffc8ab25bcc37eaf9edc815a65b_normal.png"
		alt = "Nicolas Eliaschev"
		
		out << g.render(template:'/templates/avatarPerson', model:['alt':alt, 'url':url, 'size':size, 'leyenda':attrs.leyenda])
	}
	
	def menuUsuario = { attrs ->
		if (!session.user){
			out << g.render(template:'/templates/menuLogincreate', model:[])
		}else{
			out << g.render(template:'/templates/menuUsuario', model:[])
		}
	}
	
}
